/*
 * Copyright 2012 Benoît Combe <benoit.combe@gmail.com>.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package fr.ipst.spot.entites;

import fr.ipst.spot.entites.utils.RoleAgentCnam;
import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Benoît Combe <benoit.combe@gmail.com>
 */
@Entity
@Table(name = "AgentCnam", catalog = "SPOT", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "AgentCnam.findAll", query = "SELECT a FROM AgentCnam a"),
    @NamedQuery(name = "AgentCnam.findByIdAgentCnam", query = "SELECT a FROM AgentCnam a WHERE a.idAgentCnam = :idAgentCnam"),
    @NamedQuery(name = "AgentCnam.findByIdLDAP", query = "SELECT a FROM AgentCnam a WHERE a.idLDAP = :idLDAP"),
    @NamedQuery(name = "AgentCnam.findByMail", query = "SELECT a FROM AgentCnam a WHERE a.mail = :mail"),
    @NamedQuery(name = "AgentCnam.findByNom", query = "SELECT a FROM AgentCnam a WHERE a.nom = :nom"),
    @NamedQuery(name = "AgentCnam.findByPrenom", query = "SELECT a FROM AgentCnam a WHERE a.prenom = :prenom"),
    @NamedQuery(name = "AgentCnam.findByRole", query = "SELECT a FROM AgentCnam a WHERE a.role = :role")})
public class AgentCnam extends AbstractSpotEntite implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idAgentCnam", nullable = false)
    private Integer idAgentCnam;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "idLDAP", nullable = false, length = 45)
    private String idLDAP;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "mail", nullable = false, length = 255)
    private String mail;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "nom", nullable = false, length = 255)
    private String nom;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "prenom", nullable = false, length = 255)
    private String prenom;
    @Basic(optional = false)
    @NotNull
    @Column(name = "role", nullable = false)
    @Enumerated(EnumType.ORDINAL)
    private RoleAgentCnam role;
    @OneToMany(mappedBy = "agentCnam", fetch = FetchType.LAZY)
    private List<Evenement> evenementList;

    /**
     *
     */
    public AgentCnam() {
    }

    /**
     *
     * @param idAgentCnam
     */
    public AgentCnam(Integer idAgentCnam) {
        this.idAgentCnam = idAgentCnam;
    }

    /**
     *
     * @param idAgentCnam
     * @param idLDAP
     * @param mail
     * @param nom
     * @param prenom
     * @param role
     */
    public AgentCnam(Integer idAgentCnam, String idLDAP, String mail, String nom, String prenom, RoleAgentCnam role) {
        this.idAgentCnam = idAgentCnam;
        this.idLDAP = idLDAP;
        this.mail = mail;
        this.nom = nom;
        this.prenom = prenom;
        this.role = role;
    }

    /**
     *
     * @return
     */
    public Integer getIdAgentCnam() {
        return idAgentCnam;
    }

    /**
     *
     * @param idAgentCnam
     */
    public void setIdAgentCnam(Integer idAgentCnam) {
        this.idAgentCnam = idAgentCnam;
    }

    /**
     *
     * @return
     */
    public String getIdLDAP() {
        return idLDAP;
    }

    /**
     *
     * @param idLDAP
     */
    public void setIdLDAP(String idLDAP) {
        this.idLDAP = idLDAP;
    }

    /**
     *
     * @return
     */
    public String getMail() {
        return mail;
    }

    /**
     *
     * @param mail
     */
    public void setMail(String mail) {
        this.mail = mail;
    }

    /**
     *
     * @return
     */
    public String getNom() {
        return nom;
    }

    /**
     *
     * @param nom
     */
    public void setNom(String nom) {
        this.nom = nom;
    }

    /**
     *
     * @return
     */
    public String getPrenom() {
        return prenom;
    }

    /**
     *
     * @param prenom
     */
    public void setPrenom(String prenom) {
        this.prenom = prenom;
    }

    /**
     *
     * @return
     */
    public RoleAgentCnam getRole() {
        return role;
    }

    /**
     *
     * @param role
     */
    public void setRole(RoleAgentCnam role) {
        this.role = role;
    }

    /**
     *
     * @return
     */
    @XmlTransient
    public List<Evenement> getEvenementList() {
        return evenementList;
    }

    /**
     *
     * @param evenementList
     */
    public void setEvenementList(List<Evenement> evenementList) {
        this.evenementList = evenementList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idAgentCnam != null ? idAgentCnam.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AgentCnam)) {
            return false;
        }
        AgentCnam other = (AgentCnam) object;
        if ((this.idAgentCnam == null && other.idAgentCnam != null) || (this.idAgentCnam != null && !this.idAgentCnam.equals(other.idAgentCnam))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "fr.ipst.spot.entites.AgentCnam[ idAgentCnam=" + idAgentCnam + " ]";
    }

    /**
     *
     * @return
     */
    @Override
    public Integer getId() {
        return this.idAgentCnam;
    }
}
